package com.shujia.java.day8.demo4;
import com.shujia.java.day10.demo1.Master;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        System.out.println("欢迎来到宠物店");
        Dog dog=null;//冗余
        Penguin penguin=null;
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入要领养宠物的姓名:");
        String name=sc.next();
        System.out.print("请选择要领养的宠物(1.狗 2.企鹅):");
        int i=sc.nextInt();
        int ii=0;
        switch (i){
            case 1:
                dog = new Dog();
                dog.setName(name);
                System.out.print("请选择狗的性别(1.雌 2.雄):");
                ii=sc.nextInt();
                switch (ii){
                    case 1:
                        System.out.println("雌");
                        dog.setSex("雌");
                        break;
                    case 2:
                        dog.setSex("雄");
                        break;
                }
                break;
            case 2:
                penguin = new Penguin();
                penguin.setName(name);
                System.out.print("请选择企鹅的性别(1.雌 2.雄):");
                ii=sc.nextInt();
                switch (ii){
                    case 1:
                        penguin.setSex("雌");

                        break;
                    case 2:

                        penguin.setSex("雄");
                        break;
                }
                break;
        }
        System.out.println("宠物的自白:");
        if(dog!=null){
            dog.print();
        }else {
            penguin.print();
        }
    }
}
